package com.yitiao.data_algorithms.leetcode.editor.cn;

import com.yitiao.data_algorithms.leetcode.editor.cn.base.ListNode;
import com.yitiao.data_algorithms.leetcode.editor.cn.base.TreeNode;
import sun.security.krb5.internal.crypto.Des;

class DuiChengDeErChaShuLcof {
    // 2022-08-15 13:56:39
    //leetcode submit region begin(Prohibit modification and deletion)

    /**
     * Definition for a binary tree node.
     * public class TreeNode {
     * int val;
     * TreeNode left;
     * TreeNode right;
     * TreeNode(int x) { val = x; }
     * }
     */
    class Solution {
        boolean ans = true;

        public boolean isSymmetric(TreeNode root) {
            if (root == null) return true;
            dfs(root.left, root.right);
            return ans;
        }

        private void dfs(TreeNode left, TreeNode right) {
            if (left == null && right == null) {
                return;
            } else if (left == null || right == null) {
                ans = false;
                return;
            } else if (left.val != right.val) {
                ans = false;
            }
            dfs(left.left, right.right);
            dfs(left.right, right.left);
        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}